
$(function(){
	app.confirmDelete();
});

var app = {
    /**
	 * 状态改变
     * @param el
     * @param collectionName
     * @param attr
     * @param id
     */
	toggle: function(el, collectionName, attr, id){
		$.get('/admin/changeStatus', {
			collectionName: collectionName, 
			attr: attr, 
			id: id
		}, function(data) {
			if(data.success) {
				if(el.src.indexOf('yes') != -1){
					el.src = '/admin/images/no.gif';
				}else {
					el.src = '/admin/images/yes.gif';
				}
			}
		});
	},

    /**
	 * 删除监听
     */
	confirmDelete: function (){
		$('.delete').on('click', function(){
			var flag = confirm('您确定要删除吗？');
			return flag;
		})
	},

    /**
	 * 改变排序
     */
    changeSort: function(el, collectionName, id){
    	var val = el.value;
    	$.get('/admin/changeSort', {
    		collectionName: collectionName,
			id: id,
            value: val
		}, function(data){});
	}
}
